## Loading required package: ggplot2
##
## Attaching package: 'simmer.plot'
## The following objects are masked from 'package:simmer':
##
## get_mon_arrivals, get_mon_attributes, get_mon_resources
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Computation failed in `stat_smooth()`:
## NA/NaN/Inf in foreign function call (arg 3)
## time name key value replication
## 1 15.75155 patient0 priority 1 1
## 2 32.19173 patient0 wait 2 1
## 3 43.59993 patient1 priority 3 1
## 4 62.66661 patient2 priority 1 1
## 5 74.72511 patient3 priority 1 1
## 6 85.56630 patient4 priority 1 1
## resource time server queue capacity queue_size system limit replication
## 1 doctor 0.20000 1 0 2 Inf 1 Inf 1
## 2 doctor 0.80000 2 0 2 Inf 2 Inf 1
## 3 doctor 12.65135 1 0 2 Inf 1 Inf 1
## 4 doctor 12.65135 2 0 2 Inf 2 Inf 1
## 5 doctor 15.38026 1 0 2 Inf 1 Inf 1
## 6 doctor 15.75155 2 0 2 Inf 2 Inf 1
## name start_time end_time activity_time finished
## 1 Need immediate attention0 0.20000 15.38026 15.18026 TRUE
## 2 patient0 15.75155 41.49757 25.74602 TRUE
## 3 patient1 43.59993 139.22985 92.78040 TRUE
## 4 Need immediate attention1 0.80000 146.21712 122.07154 TRUE
## 5 patient2 62.66661 151.72114 38.68639 TRUE
## 6 patient3 74.72511 180.66427 32.36346 TRUE
## replication
## 1 1
## 2 1
## 3 1
## 4 1
## 5 1
## 6 1
envs2 <- lapply(1:20, function(i) {
simmer("emmergency room") %>%
add_resource("doctor", 3) %>%
add_generator("Need immediate attention", patient, at(c(0.20,0.80))) %>%
add_generator("patient", patient, function() runif(1, 10, 30), mon = 2) %>%
run(1440)
})
resources <- get_mon_resources(envs2)
arrivals <- get_mon_arrivals(envs2)
library(gridExtra)
p1 = plot(resources, metric = "utilization")
p2 = plot(resources, metric = "usage")
p3 = plot(arrivals, metric = "flow_time")
p4 = plot(arrivals, metric = "waiting_time")
grid.arrange(p1,p2,p3,p4)
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
plot(resources, metric = "utilization")
plot(resources, metric = "usage")
plot(arrivals, metric = "flow_time")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
plot(arrivals, metric = "waiting_time")
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
plot(get_mon_attributes(envs2))
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
## Warning: Computation failed in `stat_smooth()`:
## NA/NaN/Inf in foreign function call (arg 3)
head(get_mon_attributes(envs2))
## time name key value replication
## 1 15.75155 patient0 priority 1 1
## 2 32.19173 patient0 wait 2 1
## 3 43.59993 patient1 priority 3 1
## 4 62.66661 patient2 priority 1 1
## 5 74.72511 patient3 priority 1 1
## 6 88.86171 patient2 wait 2 1
head(get_mon_resources(envs2))
## resource time server queue capacity queue_size system limit replication
## 1 doctor 0.20000 1 0 3 Inf 1 Inf 1
## 2 doctor 0.80000 2 0 3 Inf 2 Inf 1
## 3 doctor 12.65135 1 0 3 Inf 1 Inf 1
## 4 doctor 12.65135 2 0 3 Inf 2 Inf 1
## 5 doctor 15.38026 1 0 3 Inf 1 Inf 1
## 6 doctor 15.75155 2 0 3 Inf 2 Inf 1
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.